home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
SYSOP3.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
25KB
|
663 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 7-11-88 7:35 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit Sysop3;
Interface
Uses
TPCrt, Dos, Globals, TAccess, TPSTRING, TPDOS,
Exdate, Core1, Core2, Dirs, EditUsr1, Sysop1,
Msgentr, MsgMove, MsgRead;
procedure process_macro;
procedure process_newin;
procedure move_from_newin;
{==========================================================================}
Implementation
procedure process_macro;
{ Process sysop macro }
var
done, continue : Boolean;
ed_macro : StrStd;
ch : Char;
i : Integer;
begin
done := False;
repeat
WriteLn(Com);
st := prompt('Macro command <D><E><S><Q><?> ', 80, 'ES?');
if Length(st) = 1 then
ch := st[1]
else
ch := '?';
case ch of
'D' :
WriteLn(Com, macro);
'E' :
begin
continue := True;
Assign(macro_file, 'MACRO.LST');
{$I-}
Reset(macro_file); {$I+}
if IoResult = 0 then
begin
WriteLn(Com);
WriteLn(Com,
'The MACRO.LST file exists and must be edited with a text editor.');
continue := ask('do you want to edit the in-memory macro', 'Y');
Close(macro_file);
end;
if continue then
begin
WriteLn(Com, 'Remember, the edited macro is NOT saved to disk.');
WriteLn(Com);
ed_macro := macro;
GetStr(ed_macro, ch, 79, 'ES');
WriteLn(Com);
macro := ed_macro;
SetSect(HomName);
end;
end;
'S' :
begin
done := True;
Assign(macro_file, 'MACRO.LST');
{$I-}
Reset(macro_file); {$I+}
if IoResult = 0 then
begin
if ask('Do you want to execute the MACRO.LST file', 'Y') then
begin
macro_file_exists := True;
WriteLn('Starting macro execution.');
macro_in_progress := True;
end
else
Close(macro_file);
end;
if (not macro_file_exists) and (Length(macro) > 0) then
begin
WriteLn('Starting macro execution.');
macro_in_progress := True;
st := macro;
repeat
i := Pos('^M', st);
if i > 0 then
begin
Delete(st, i, 2);
Insert(Chr(13), st, i);
end;
until i = 0;
Cmd_Queue := st;
mult_cmds := True;
end;
end;
'Q' :
done := True
else
WriteLn(Com, '<D>isplay, <E>dit, <S>tart, <Q>uit');
end;
until (done) or (not Online);
end;
procedure process_newin;
{ Process and update newin file (add, delete, edit, hide, and release) }
var
ch, ch_sel : Char;
x : Integer;
rec : LongInt;
Str : StrTAD;
ed_descr, line : StrStd;
Dirspec : StrPr;
TmpDrv : Str3;
temp_user_rec : user_list;
fname, work,
junk : DosFileName;
found,
none_found,
edited,
one_section : Boolean;
fdrive : Str3;
req, req_new : string;
begin
SetSect(HomName);
fname := '';
one_section := True;
none_found := True;
found := False;
rec := 0;
line := ' |---------- File Description -----------------------------------------------|';
work := 'NEWIN';
FindSect(work, TmpDrv, OK);
if OK then
begin
Dirspec := TmpDrv;
if (Length(HomName) > 3) and (Dirspec = HomDrv) then
begin
Dirspec := Dirspec+Copy(HomName, 4, Length(HomName));
Dirspec := Dirspec+'\';
end;
Dirspec := Dirspec+'NEWIN';
rec := Pred(FileSize(nwin_file));
end
else
WriteLn(Com, 'NEWIN section not found.');
WriteLn(Com);
if (OK) and (rec < 1) then
if (ask('File Empty: Add first Record', 'Y')) then
with nwin_rec do
begin
name := correct_fn(prompt('File name', 12, 'ES'));
if name <> '' then
begin
while (Length(name)-Pos('.', name)) < 2 do
name := name+'-';
WriteLn(Com, line);
descr := prompt('', 75, 'EL');
GetTAD(date);
user := user_loc;
sectn := get_section_name('D');
rec := FileSize(nwin_file);
status := public;
dnloads := 0;
for x := 0 to 5 do
last_dnload[x] := 0;
rec := 1;
Seek(nwin_file, rec);
Write(nwin_file, nwin_rec);
WriteLn(Com);
WriteLn(Com, 'First Record recorded.');
WriteLn(Com);
end;
end;
if OK and (rec >= 1) and ask('Search by File(s)', 'N') then
fname := prompt('Enter filename (partial name OK) ', 12, 'ES');
if (fname <> ' ') and (fname <> '') then
one_section := False;
if OK and (rec >= 1) and one_section and ask('Search by Section', 'N') then
fname := prompt('Enter Section name ', 12, 'ES');
abort := False;
while Online and OK and (rec >= 1) and (not brk) do
with nwin_rec do
begin
if (fname = '') or (fname = ' ') then
begin
Seek(nwin_file, rec);
Read(nwin_file, nwin_rec);
end
else
begin
found := False;
while OK and (rec >= 1) and (not found) and (not brk) and Online do
begin
Seek(nwin_file, rec);
Read(nwin_file, nwin_rec);
if (not one_section) then
work := name
else
work := sectn;
if Equal_names(fname, work) or (Pos(work, fname) = 1) then
begin
found := True;
none_found := False;
end
else
rec := Pred(rec);
end;
if (not found) and (rec < 1) then
begin
OK := False;
WriteLn(Com);
if none_found then
WriteLn(Com, 'File not found in Newin listings.');
end;
end;
if OK then
begin
if (user > 0) and (user <= FileLen(DatF)) then
begin
GetRec(DatF, user, temp_user_rec);
if temp_user_rec.used <> 0 then
begin
temp_user_rec.fn := 'Purged';
temp_user_rec.ln := 'User';
end;
end
else
begin
temp_user_rec.fn := 'Unknown';
temp_user_rec.ln := 'Sender';
end;
WriteLn(Com);
case status of
private :
Write(Com, 'Hidden ');
public :
Write(Com, 'Released ');
deleted :
Write(Com, 'Deleted ')
end;
Str := intstr(date[4], 2)+'/'+intstr(date[3], 2)+'/'+intstr(date[5], 2);
Write(Com, pad(name, 15), ' Section: ', sectn, ' ', Str, ' ');
WriteLn(Com, temp_user_rec.fn, ' ', temp_user_rec.ln);
Str := intstr(last_dnload[4], 2)+'/'+intstr(last_dnload[3], 2)+'/'+intstr(
last_dnload[5], 2);
Write(Com, 'Number downloads ', dnloads, ' Last download ', Str);
if CreditType = Points then
Write(Com, ' Points ', PointValue);
WriteLn(Com);
WriteLn(Com, descr);
edited := False;
repeat
WriteLn(Com);
st := prompt('Newin Command <A><D><E><H><P><R><U><M><Q><?> ', 80,
'ES?');
if st = ' ' then
ch_sel := 'S'
else if Length(st) = 1 then
ch_sel := st[1]
else
ch_sel := '?';
case ch_sel of
'A' :
begin
name := correct_fn(prompt('File name', 12, 'ES'));
if name <> '' then
begin
junk := name;
FindKey(NewinName, rec, junk);
if OK then
begin
WriteLn(Com);
WriteLn(Com, 'File is already listed.');
ch_sel := 'S';
end
else
begin
while (Length(name)-Pos('.', name)) < 2 do
name := name+'-';
WriteLn(Com, line);
descr := prompt('', 75, 'EL');
GetTAD(date);
user := user_loc;
sectn := get_section_name('D');
rec := FileSize(nwin_file);
status := public;
dnloads := 0;
for x := 0 to 5 do
last_dnload[x] := 0;
end;
end
else
ch_sel := 'S';
end;
'D' :
begin
status := deleted;
if ask('Delete file also', 'N') then
begin
FindSect(nwin_rec.sectn, fdrive, found);
if found then
begin
if (fdrive = HomDrv) and (Length(HomName) > 3) then
req := HomName+'\'
else
req := fdrive;
req := req+nwin_rec.sectn+'\'+nwin_rec.name;
req_new := DirSpec+'\'+nwin_rec.name;
{$I-}
Assign(temp_file, req_new);
Erase(temp_file);
if IoResult <> 0 then
begin
Assign(temp_file, req);
Erase(temp_file);
if IoResult <> 0 then
WriteLn(Com, 'File not found.');
end;
{$I+}
end;
end;
end;
'E' :
begin
edited := True;
WriteLn(Com);
if ask('Change File name', 'N') then
begin
junk := name;
DeleteKey(NewinName, rec, name);
name := correct_fn(prompt('New File Name', 12, 'ES'));
if name = '' then
name := junk
else
junk := name;
AddKey(NewinName, rec, junk);
FlushIndex(NewinName)
end;
WriteLn(Com);
WriteLn(Com, line);
Write(Com, ' ');
ed_descr := descr;
GetStr(ed_descr, ch, 75, 'E');
descr := ed_descr;
WriteLn(Com);
WriteLn(Com);
Write(Com, 'Present section is ', sectn, '. ');
if ask('Change it', 'N') then
begin
DeleteKey(NewinArea, rec, sectn);
sectn := get_section_name('D');
junk := sectn;
AddKey(NewinArea, rec, junk);
FlushIndex(NewinArea)
end;
if CreditType = Points then
begin
Write(Com, 'Present Point Value is ', PointValue, '. ');
if ask('Change it', 'N') then
begin
PointValue := strint(prompt('Point Value ', 5, 'EL'));
end;
end;
end;
'H' :
status := private;
'R' :
begin
case CreditType of
KiloBytes :
begin
PointValue := 0;
FindSect(nwin_rec.sectn, fdrive, found);
if found then
begin
if (fdrive = HomDrv) and (Length(HomName) > 3) then
req := HomName+'\'
else
req := fdrive;
req := req+nwin_rec.sectn+'\'+nwin_rec.name;
req_new := DirSpec+'\'+nwin_rec.name;
{$I-}
Assign(temp_file, req_new);
Reset(temp_file);
if IoResult <> 0 then
begin
Assign(temp_file, req);
Reset(temp_file);
if IoResult <> 0 then
WriteLn(Com,
'File not found, filesize set to 0k..')
else
begin
if FileSize(temp_file) > 0 then
PointValue := FileSize(temp_file) div 1024;
Close(temp_file);
end;
end
else
begin
if FileSize(temp_file) > 0 then
PointValue := FileSize(temp_file) div 1024;
Close(temp_file);
end;
{$I+}
end;
end;
Files :
PointValue := 1;
end;
status := public;
GetTAD(date);
WriteLn(Com);
if ask('Credit file to uploader', 'Y') then
begin
edit_user(temp_user_rec.fn, temp_user_rec.ln,
PointValue);
end;
end;
'P' :
begin
if (fname <> '') and (fname <> ' ') then
begin
found := False;
abort := False;
if rec < Pred(FileSize(nwin_file)) then
Inc(rec);
while OK and (rec < FileSize(nwin_file)) and Online and (not
found) and (not brk) do
begin
Seek(nwin_file, rec);
Read(nwin_file, nwin_rec);
if (not one_section) then
work := Expand_Filename(nwin_rec.name)
else
work := sectn;
if Equal_names(fname, work) then
found := True
else if rec < Pred(FileSize(nwin_file)) then
Inc(rec)
else
OK := False;
end;
end
else
begin
if rec < Pred(FileSize(nwin_file)) then
Inc(rec)
else
OK := False;
end;
end;
'S' :
begin {skip function dummy}
end;
'U' :
begin
edit_user(temp_user_rec.fn, temp_user_rec.ln, 0);
WriteLn(Com);
end;
'M' :
begin
mesg_enter('M');
WriteLn(Com);
end;
'Q' :
OK := False;
else
WriteLn(Com,
'<A>dd, <D>el, <E>dit, <H>ide, <P>rev, <R>elease, <U>ser Edit, <M>esg, <Q>uit')
end;
until (ch_sel in ['A', 'D', 'E', 'H', 'P', 'R', 'S', 'M', 'U', 'Q']) or (not Online);
if ch_sel in ['A', 'D', 'H', 'R'] then
begin
if (ch_sel in ['H', 'R']) then
begin
SetSect(HomName); {set up for loading overlay}
hide_release(name, status, Dirspec);
SetSect(HomName); {re-set after using overlay}
end;
mode := files_mode; { enable all files to be read}
ReadDir(DirEntries, DirSpace, DirBase);
SetSect(HomName);
mode := sysop_mode; {reset to current mode}
end;
if (ch_sel in ['A', 'D', 'H', 'R']) or edited then
begin
Seek(nwin_file, rec);
Write(nwin_file, nwin_rec);
case ch_sel of
'A' :
begin
WriteLn(Com, 'Newin Entry ADDED.');
junk := sectn;
AddKey(NewinArea, rec, junk);
junk := name;
AddKey(NewinName, rec, junk);
end;
'D' :
WriteLn(Com, 'Newin Entry DELETED.');
'H' :
WriteLn(Com, 'Newin Entry marked HIDDEN.');
'R' :
WriteLn(Com, 'Newin Entry marked RELEASED.');
end;
end;
if (not(ch_sel in ['P', 'A', 'U', 'M'])) and (not edited) then
rec := Pred(rec);
end; {ok}
end; {while}
end;
procedure move_from_newin;
{ Move aged files from Newin to appropriate area }
var
rec : Integer;
Dirspec,
NewDirspec : StrPr;
TmpDrv : Str3;
work : DosFileName;
procedure make_path(var Dir : StrPr; section : DosFileName);
begin
if (Length(HomName) > 3) and (Dir = HomDrv) then
begin
Dir := Dir+Copy(HomName, 4, Length(HomName));
Dir := Dir+'\'
end;
Dir := Dir+section;
end;
procedure check_dirs;
var
This : SectPtr;
TmpDirspec : StrPr;
TmpSection : DosFileName;
SameDrive : Boolean;
begin
This := SectBase;
while This <> nil do
begin
TmpSection := This^.SectName;
TmpDirspec := This^.SectDrive+':\';
if TmpDirspec = HomDrv then
SameDrive := True
else
SameDrive := False;
make_path(TmpDirspec, TmpSection);
if TmpSection <> 'SYSTEM' then
begin
if SameDrive then
Delete(TmpDirspec, 1, 2);
{$I-}
ChDir(TmpDirspec) {$I+} ;
if IoResult = 0 then
SetSect(HomName)
else
MkDir(TmpDirspec);
end;
This := This^.Next;
end;
end;
begin
SetSect(HomName);
WriteLn(Com);
check_dirs;
if ask('Move files from the NEWIN section', 'Y') then
begin
rec := 1;
work := 'NEWIN';
FindSect(work, TmpDrv, OK);
if OK then
begin
Dirspec := TmpDrv;
make_path(Dirspec, work);
rec := Pred(FileSize(nwin_file))
end
else
WriteLn(Com, 'NEWIN section not found, aborting...');
WriteLn(Com);
OK := (rec > 1);
if OK then
with nwin_rec do
begin
WriteLn(Com, 'Moving files from NEWIN...Please wait...');
WriteLn(Com);
while rec > 1 do
begin
Seek(nwin_file, rec);
Read(nwin_file, nwin_rec);
FindSect(sectn, TmpDrv, OK);
NewDirspec := TmpDrv;
if OK then
make_path(NewDirspec, sectn)
else
WriteLn(Com, name, ' shows invalid section name of ', sectn);
if (day_diff(date[3], date[4], date[5]+1900, login_t[3], login_t[4],
login_t[5]+1900) > new_days) and OK and (status <> private) and
(status <> deleted) and ExistFile(Dirspec+'\'+name) then
begin
WriteLn(Com, 'Copying ', name, ' to ', sectn);
errcode := ExecDos(CommandPath+' /C COPY '+Dirspec+'\'+name+' '+
NewDirspec+' > nul', False, nil);
if (not ExistFile(NewDirspec+'\'+name)) then
WriteLn(Com, 'Copy wasn''t sucessful.')
else if Dirspec = NewDirspec then
WriteLn(Com, name, ' shows NEWIN as it''s area.')
else
begin
WriteLn(Com, 'Deleting ', name);
Assign(byte_file, Dirspec+'\'+name);
Erase(byte_file)
end;
end;
Dec(rec)
end;
end;
mode := files_mode;
ReadDir(DirEntries, DirSpace, DirBase);
mode := sysop_mode;
end;
end;
end. { of SYSOP3.PAS}